|
|
|
|
|
|
|
Dim Valuebuffer As String
Dim ValueCollection As New Collection
Dim currentValue As clsKeyValues
Dim nulloffset As Long
res = GetValueInfo(hKey, NumberOfSubValues, MaxSubValueLength)
If res <> 0 Then
Exit Function
End If
Valuebuffer = String$(MaxSubValueLength + 1, 0)
For ValueIndex = 0 To NumberOfSubValues - 1
res = RegEnumValue(hKey, ValueIndex, Valuebuffer, _
MaxSubValueLength, 0, 0, 0, 0)
If res = 0 Then
nulloffset = InStr(Valuebuffer, Chr$(0))
If nulloffset<=1 Then
ValueCollection.Add "Default"
Else
ValueCollection.Add Left$(Valuebuffer, nulloffset-1)
End If
End If
Next ValueIndex
Set EnumerateValues = ValueCollection
End Function |
|
|
|
|
|
|
|
|
The program has been extended with a second list box. The Form_Load event has been extended to load the first list box with the list of subkey names returned by the EnumerateKeys function, using the following code: |
|
|
|
|
|
|
|
|
Set keylist = EnumerateKeys(rootkey)
For Each currentkey In keylist
List1.AddItem currentkey.KeyName
Next
Set GlobalKeyCollection = keylist |
|
|
|
|
|
|
|
|
When you click on the list box, the List1_Click function is called. This function searches for the corresponding clsKeyValues object in the GlobalKeyCollection collection. When it finds the correct object, it clears the second list box and loads it with the names of the values for that subkey, using the following code: |
|
|
|
|
|